﻿using C1.Silverlight.Pdf;
using System.Windows.Media;
using System;
using System.Windows;
using System.Collections.Generic;

namespace MyFloridaHouse.libSvOpenDistricts.PDF
{
    public class HouseMapFooterCreatedOn
    {
        public static void Draw(C1PdfDocument pdf, PDFPoint cursor, double borderWidth, double borderHeight)
        {
            if (null == pdf) return;
            if (null == cursor) return;
            if (borderHeight < 1) return;
            if (borderHeight < 1) return;
            
            // draw border 
            Pen pen = new Pen(Colors.Black, 1.0);


            // draw file name
            List<PDFString> stringList = new List<PDFString>();
            //PDFString fileNameString = new PDFString(pdf, "Arial", 1, PdfFontStyle.Regular, Colors.Black, fileName, 1);
            //stringList.Add(fileNameString);

            double topPaddingPercent = .05;
            //            double nameHeightPercent = .45;
            //            double midPaddingPercent = .1;
            //            double dateHeightPercent = .4;

            //double textPadding = PDFdoc.SetStringListFontSizeToFit(stringList, borderWidth, borderHeight * nameHeightPercent, 1);
            //double textFontSize = fileNameString.fontSize;
            //double textHeight = fileNameString.textBoxSize.Height;

            //PDFPoint fileInfoCursor = new PDFPoint(cursor.x, cursor.y);
            //fileInfoCursor.AddY(borderHeight * topPaddingPercent + textPadding);
            //fileNameString.DrawCenteredX(new Rect(fileInfoCursor.x, fileInfoCursor.y, borderWidth, fileNameString.textBoxSize.Height));



            // draw file timestamp info
            stringList.Clear();
            PDFString mapGeneratedOn = new PDFString(pdf, "Arial", 1, PdfFontStyle.Regular, Colors.Black, "Map Generated On", 1);
            stringList.Add(mapGeneratedOn);
            PDFString mapGeneratedDate = new PDFString(pdf, "Arial", 1, PdfFontStyle.Regular, Colors.Black, DateTime.Now.ToShortDateString(), 1);
            stringList.Add(mapGeneratedDate);

            double textPadding = PDFdoc.SetStringListFontSizeToFit(stringList, borderWidth, borderHeight, 3);
            double textFontSize = mapGeneratedOn.fontSize;
            double textHeight = mapGeneratedOn.textBoxSize.Height;

            PDFPoint textCursor = new PDFPoint(cursor.x, cursor.y);
            textCursor = new PDFPoint(cursor.x, cursor.y);
            textCursor.AddY(borderHeight * (topPaddingPercent) + textPadding);
            foreach (var str in stringList)
            {
                str.DrawCenteredX(new Rect(textCursor.x, textCursor.y, borderWidth, str.textBoxSize.Height));
                textCursor.AddY(str.textBoxSize.Height + textPadding);
            }
        }

    }
}
